﻿@{
    Layout = null;
}

<!DOCTYPE html>

<html>
<head>
    <title>Index</title>
    <script src="../../Scripts/jquery-1.5.1.min.js" type="text/javascript"></script>
    <script src="../../Scripts/jquery.easyui.min.js" type="text/javascript"></script>

    <link href="../../Content/easyUI/themes/default/easyui.css" rel="stylesheet" type="text/css" />
    <link href="../../Content/easyUI/themes/icon.css" rel="stylesheet" type="text/css" />
    <script type="text/javascript">
        $(function () {
            $("#tt").tabs();
            //获取菜单组（权限组）
            $.get("/Home/LoadMenu", {}, function (data) {
                for (var i in data) {
                    //新添加一个menu
                    $('#aa').accordion('add', {
                        title: data[i].GroupName,
                        //menu(权限组)下的内容（权限），以p标签包裹的a标签
                        content: makeMenuContent(data[i])
                    });
                }
                //绑定menu点击事件
                bindMenuClick();
            }, 'json');
        });

        function makeMenuContent(actionGroup){
            var str = "";
            var menuItems = actionGroup.MenuItems;
            var len = menuItems.length;
            for (var i = 0; i < len; i++) {
                //将href 设为javascript:void(0)，防止跳转，设置的url属性是给js使用的，class属性是为了方便进行menu点击事件的绑定
                //如果写成 javascript:void()，在点击后 会有错误，待查
                str += '<p><a href="javascript:void(0)" class="menuLink" url=' + menuItems[i].Url + '>' + menuItems[i].ActionInfoName + "</a></p>";
            }
            return str;
        }

        function bindMenuClick() {

            $(".menuLink").click(function () {
                var _title = $(this).text();
                var table = $('#tt');
                if (!table.tabs('exists', _title)) {
                    var url = $(this).attr('url');
                    //首先通过'exists'方法判断页签是否已经存在，若不存在则往table中添加一个页签
                    table.tabs('add', {
                        title: _title,
                        iconCls: 'icon-save',
                        closable: true,
                        content: makeTabContent(url)
                    });
                } else {
                    //如果已经存在，则将焦点放在相应的页签上
                    table.tabs('select', _title);
                }

            });
            
       }

       function makeTabContent(url) {
            var strHtml='';
            strHtml = '<iframe style="width: 100%; height: 100%" src=' + url + '></iframe>';
            return strHtml;
       }
    </script>
</head>
<body class="easyui-layout">
    <iframe src style="width: 100%; height: 100%"><p>hahahaah</p></iframe>
    <!---------------------------网站顶部区域------------------------------------------------------->
    <div region="north" border="false" style="height: 72px; background: url('../../Content/Images/3.jpg');
        background-repeat: repeat-x;">
        
    </div>
    <!---------------------------网站左边导航区域------------------------------------------------------->
    <div region="west" split="true" title="菜单导航" style="width: 150px;">
        <div id="aa" class="easyui-accordion" style="text-align: center">
        </div>
    </div>

    <!---------------------------网站中间工作内容区域------------------------------------------------------>
    <div region="center" title="后台管理>>权限组管理" style="width: 100%;">
        <div id="tt" style="" fit="true">
        </div>
    </div>

    <!---------------------------网站底部区域------------------------------------------------------->
    <div region="south" border="false"  style="height: 25px; background: #A9FACD; text-align: center;">
        <span>2012-2013</span>
    </div>
</body>
</html>
